package com.carepulse.query;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class PDSLEngineServiceWrapper
 */
@WebServlet("/QueryServiceWrapper")
public class QueryServiceWrapper extends HttpServlet {
    private static final long serialVersionUID = 1L;
    RubyQueryService rubyservice;   
    /**
     * @see HttpServlet#HttpServlet()
     */
    public QueryServiceWrapper() {
        super();
        // TODO Auto-generated constructor stub
    }
    public void init() throws ServletException{
        System.out.println("Starting and initializing the Service.......");
        String dbconfigpath=this.getServletConfig().getInitParameter("DBCONFIGPATH");
        RubyQueryService.init_service(dbconfigpath);
        rubyservice = new RubyQueryService(this.getServletContext());
        System.out.println("Service is Started!");
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        rubyservice.doGet(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        rubyservice.doPost(request,response);
    }

    /**
     * @see HttpServlet#doPut(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        rubyservice.doPut(request,response);
    }

    /**
     * @see HttpServlet#doDelete(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        rubyservice.doDelete(request,response);
    }


}
